package com.testmall.controller;

import com.github.pagehelper.Page;
import com.testmall.entity.Comment;
import com.testmall.entity.common.PageBean;
import com.testmall.entity.common.ResultBean;
import com.testmall.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(tags = "评论管理")
@RestController
@RequestMapping("/api/comment")
public class CommentController extends BaseController {
    @Autowired
    CommentService commentService;
    @ApiOperation(value = "评论或回复评论")
    @PostMapping("/save")
    public ResultBean save(@RequestBody Comment comment){
        int rs=commentService.savecomment(comment);
        return rs>0?success("评论成功"):fail("评论失败");
    }

    @ApiOperation("商品评论列表")
    @PostMapping("/query")
    public ResultBean query(@RequestBody Map map){
        //return commentService.querycomment(map);
        return success("商品评论",commentService.querycomment(map));
    }

}
